<?php


namespace app\common\validate;


use think\Validate;

class Vld_User extends Validate //验证 管理员规则
{
    //验证规则 管理员
    protected $rule=[
        'username|用户名'=>'require|length:2,8|unique:user',
        'password|密码'=>'require|length:6,8',

    ];
    protected $message  =   [
        'username.require' => '用户名必填！',
        'username.length'     => '用户名长度为2-8个字符！',
        'username.unique' => '用户名不能重复',
        'password.require'   => '密码必填！',
        'password.length'   => '密码长度为6-8个字符！',




    ];
    //验证场景
    // login 登录
    //register 注册
    protected  $scene=[
        'login'=>['username','password'],
        'register'=>['username','password','conpassword','nickname','email'],
        'reset'=>['code'],
        'forget'=>['emailf'],
    ];
    public function sceneLogin()
    {   // login 登录方法
        return $this->only(['username','password'])
            ->remove('username', 'unique'); //过滤不需要的 unique规则;
    }
}
